<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class OnlineExhibition extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'online_exhibitions';

    //展厅介绍 序言
    public function  onlineExhibitionIntroduction(){
        //
        return $this->hasOne(OnlineExhibitionIntroduction::class);
    }
    //艺术评论
    public function onlineExhibitionEvaluation(){
        return $this->hasOne(OnlineExhibitionEvaluation::class);
    }

    //实体展讯
    public function onlineExhibitionLiveReport(){
        return $this->hasOne(OnlineExhibitionLiveReport::class);
    }
    //展厅相册
    public function  onlineExhibitionPhotos(){
        return $this->hasMany(OnlineExhibitionPhoto::class);
    }

    //媒体报道
    public function  onlineExhibitionReports(){
        return $this->hasMany(OnlineExhibitionReport::class);
    }

    //涉及到的作家
    public function authors():BelongsToMany{
        $pivotTable = 'online_exhibition_authors'; // 中间表

        $relatedModel = Author::class; // 关联模型类名

        return $this->belongsToMany($relatedModel, $pivotTable, 'online_exhibition_id', 'author_id');
    }
}
